#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void swap(char*buf1,char*buf2,int width) {
	for (int i = 0; i < width; i++) {
		char j = *buf1;
		*buf1 = *buf2;
		*buf2 = j;
		buf1++;
		buf2++;
	}
}
int cmp_int(const void*p1,const void*p2) {
	return *((int*)p1) - *((int*)p2);
}
void similar_qsort(void*base,size_t sz,size_t width,int (*cmp)(const void*p1,const void*p2)) {
	for (int i = 0; i < sz - 1; i++) {
		for (int j = 0; j < sz - i - 1; j++) {
			if (cmp((char*)base + j * width, (char*)base + (j + 1) * width) > 0) {
				swap((char*)base + j * width, (char*)base + (j + 1) * width, width);
			}
		}
	}
}
int main()
{
	int arr[] = { 1,5,6,7,1,0,2,5,1,8 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	similar_qsort(arr, sz, sizeof(arr[0]), cmp_int);
	for (int i = 0; i < sz; i++) {
		printf("%d ", arr[i]);
	}
	return 0;
}